package com.hqd.jjvm.util;

import org.apache.commons.lang.StringUtils;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipFile;

import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;

public class FileUtil {
	public static void readZipFile(String path, String suffix) throws IOException {
		readZipFile(new File(path), suffix);
	}

	public static void readZipFile(File file, String suffix) throws IOException {
	}

	public static List<String> getZipFileNames(String path, String suffix) throws IOException {
		List<String> list = new LinkedList<>();
		if (StringUtils.isNotBlank(path)) {
			ZipFile zipFile = new ZipFile(path);
			Enumeration<ZipEntry> entries = zipFile.getEntries();
			while (entries.hasMoreElements()) {
				ZipEntry zipEntry = entries.nextElement();
				if (!zipEntry.isDirectory() && zipEntry.getName().endsWith(suffix))
					list.add(zipEntry.toString());
			}
		}
		return list;
	}
}
